package Sampling;

import java.util.ArrayList;

import Definitions.GraphClass;
import Global.GlobalClass;

public class CoTrainSamplingClass extends SamplingAbstractClass{

	int testSize;
	int unusedSize;
	int unlabeledSize;
	int validationSize;
	
	public CoTrainSamplingClass(GraphClass currentGraph, GlobalClass global, double testRatio, double valRatio, double unusedRatio, double unlabeledRatio) {	 
		super(currentGraph, global, testRatio, valRatio, unusedRatio, unlabeledRatio);
		int dataSize = currentGraph.getDataSet().size();

		this.testSize = (int)((double)dataSize * this.testRatio);
		this.unusedSize = (int)((double)dataSize * this.unusedRatio);
		this.unlabeledSize = (int)((double)dataSize * this.unlabeledRatio);
		this.validationSize = (int) ((double)dataSize * this.valRatio);

	}

	@Override
	public void generateSampling(GraphClass g, int fold) {
	
		ArrayList<Integer> nodeIdList = new ArrayList<Integer>();
		int currentIndex = 0;
		
		for(int i=0 ; i< g.getDataSet().size(); i++)
		{
			nodeIdList.add(i);
		}
		
		shuffle(nodeIdList, fold+1);
		
		for(int i= 0; i< this.testSize ; i++, currentIndex++)
		{
			this.addNodeToTestSet(g.getDataSet().get(nodeIdList.get(currentIndex))); 
		}
		
		for(int i= 0; i< this.validationSize; i++, currentIndex++)
		{
			this.addNodeToValidationSet(g.getDataSet().get(nodeIdList.get(currentIndex))); 			
		}
		
		for(int i= 0; i< this.unlabeledSize; i++, currentIndex++)
		{
			this.addNodeToUnlabeledSet(g.getDataSet().get(nodeIdList.get(currentIndex))); 
		}
		
		for(int i= 0; i< this.unusedSize; i++, currentIndex++)
		{
			this.addNodeToUnusedSet(g.getDataSet().get(nodeIdList.get(currentIndex))); 
		}
		
		while(currentIndex < g.getDataSet().size())
		{
			this.addNodeToTrainingSet(g.getDataSet().get(nodeIdList.get(currentIndex)));
			currentIndex++;
		}
		
		System.out.print("Train size: " + this.getTrainNodes().size());
		
		System.out.println("Unlabeled: " + this.unlabeledSize + " Unused: " + this.unusedSize+ " Test: " + this.testSize + " Validation " + this.validationSize );
	}

	@Override
	public void generateSampling(GraphClass g) {
		
	}
	
}
